{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Plotting experimental pole figures in the form of EPF (popLA)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Populating the interactive namespace from numpy and matplotlib\n"
     ]
    }
   ],
   "source": [
    "%pylab inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from TX import upf"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- File named 'fss.epf' in the format of popla. Find in below that the miller index for the pole is parenthesized - the parenthesis are used as delimiter bewteen pole figure blocks"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "** Needs header here\r\n",
      "(110)  5.0 80.0  5.0360.0 1 1 2-1 3   99    1\r\n",
      " 225322972305220021792084186317811767182118771989216621852207226022692215\r\n",
      " 221422552224220622032064206621072215220621712227223622392269221121472174\r\n"
     ]
    }
   ],
   "source": [
    "!head -n 4 ../mat/fss.epf"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- There are three types: Bruker, steglich, epf. Type 'epf' for popLA format when prompted"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Type the experimental polfe figure mode\n",
      "Available options: bruker, steglich, epf (default: epf)\n",
      " >>>\n",
      "You are now reading experimental pole figure(s) :../mat/fss.epf\n",
      "number of pole figures: 3\n",
      "dkhi, dphi 5.0 5.0\n",
      "khi range 0.0 90.0\n",
      "phi range 0.0 360.0\n",
      "dkhi, dphi 5.0 5.0\n",
      "khi range 0.0 90.0\n",
      "phi range 0.0 360.0\n",
      "dkhi, dphi 5.0 5.0\n",
      "khi range 0.0 90.0\n",
      "phi range 0.0 360.0\n"
     ]
    }
   ],
   "source": [
    "mypf=upf.polefigure(epf='../mat/fss.epf')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- The example pole figure was measured using X-ray upto a tilting angle of 80. To indicate the boundary of $\\psi=80^\\circ{}$, use $\\verb|iline_khi80=True|$ - a broken gray line shows up."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- Also, there are three pole figure blocks present in the file. Thus, three pole figures are plotted"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "List of files:\n",
      "../mat/fss.epf \n",
      "ifig= None\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/yj/anaconda/lib/python2.7/site-packages/matplotlib/contour.py:1538: UserWarning: Log scale: values of z <= 0 have been masked\n",
      "  warnings.warn('Log scale: values of z <= 0 have been masked')\n"
     ]
    }
   ],
   "source": [
    "fig=mypf.pf_new(iline_khi80=True,mn=0.8)\n",
    "fig.tight_layout()\n",
    "fig.savefig('fss.pdf',bbox_inches='tight')"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
